// http://acm.hdu.edu.cn/webcontest/contest_showproblem.php?pid=1001&ojid=0&cid=14153&hide=0
#include <iostream>
using namespace std;

bool trace[10000];

int main()
{
    ios::sync_with_stdio(false);
    int C, m, n;
    cin >> C;
    while(C--)
    {
        cin >> n >> m;
        trace[0] = false; // 终点都是必败点
        for(int i=1; i <= n; i++)
        {
            if(i<=m)
            {
                trace[i] = true;
            }
            else
            {
                trace[i] = false;
                for(int j=i-1; j >= i-m; j--)
                {
                    if(trace[j] == false)
                    {
                        trace[i] = true;
                        break;
                    }
                }
            }
        }
        if(trace[n])
        {
            cout << "first" << endl;
        }
        else
        {
            cout << "second" << endl;
        }
    }
    return 0;
}